/*
 * jquery 1.32
 * 图片的弹出
 * 2012-08-22
 * 放置图片的层<a href="#" class="js-aBox" data-img=""><img src="" /></a>
 */

var width = $(window).width();
var height0 = $(window).height();
function Uz_layer() {
        //创建遮罩层
        var height1 = $("body").height();
        height = height0 > height1 ? height0 : height1;
        var layer = $("<div id=\"JS-layer\"></div>");
        $("body").append(layer);
        $("#JS-layer").css({
                zIndex: "998",
                position: "absolute",
                top: "0px",
                left: "0px",
                height: height + "px",
                width: "100%",
                backgroundColor: "black",
                opacity: "0.3",
                filter: "alpha(opacity=30)"
        });
}
function Uz_thickIMG() {
        Uz_layer();
        var scrollTop = $(window).scrollTop();
        //获取img大小
        var src = $(".js-aBox").attr("data-img");
        var oimg = new Image();
        oimg.src = src;
        var Sheight = oimg.height;
        var Swidth = oimg.width;

        //创建img层
        var ImgBox = $("<div id=\"JS-ImgBox\"><div class=\"ImgBox\"><a href=\"####\" id=\"JS-ImgClose\" title=\"点击关闭\"></a><img src=\"\" id=\"JS-imgCon\"/></div></div>");
        $("body").append(ImgBox);
        $("#JS-ImgBox").css({
                zIndex: "999",
                position: "absolute",
                top: (height0 - Sheight) / 2 + scrollTop + "px",
                left: (width - Swidth) / 2 + "px"
        });
        $(".ImgBox").css({
                position: "relative",
                padding: "10px",
                backgroundColor: "#f3f3f3"
        });
        $("#JS-ImgClose").css({
                backgroundImage: "url(/Public/kanghui/images/content/recently-icon.jpg)",
                backgroundPosition: "-38px 0",
                height: "23px",
                width: "21px",
                display: "block",
                position: "absolute",
                right: "0px",
                top: "0px"
        });
        $("#JS-imgCon").attr("src", src);
        $("#JS-ImgClose,#JS-layer").click(function() {
                $("#JS-ImgBox").remove();
                $("#JS-layer").remove();
        });
}

/*
 * jquery 1.32
 * @iframe div
 *h 为层的高
 *w 为层的宽
 *targeturl 为层的id或者iframe的url
 */
function editWidget2(targeturl, h, w) {
        Uz_layer();
        var scrollTop = $(window).scrollTop();
        var size = {'height': h, 'width': w};
        var iframe = document.createElement('iframe');
        iframe.name = 'Widget Editor';
        iframe.id = 'WidgetEditor';
        iframe.scrolling = "no";
        iframe.src = targeturl;
        iframe.style.height = size.height + 'px';
        iframe.style.width = size.width + 'px';
        iframe.style.position = 'absolute';
        iframe.style.zIndex = 9999;
        iframe.style.border = "2px";
        iframe.frameBorder = "0px";
        iframe.marginwidth = "0";
        iframe.marginheight = "0";
        iframe.style.top = ((height0 - size.height) / 2) + document.documentElement.scrollTop + 'px';
        iframe.style.left = (width / 2) - (size.width / 2) + 'px';
        document.body.appendChild(iframe);
}
function thickDiv(targeturl, h, w) {
        Uz_layer();
        var scrollTop = $(window).scrollTop();
        var size = {'height': h, 'width': w};
        var $targeturl = $(targeturl);
        $targeturl.show();
        var left = (width - size.width) / 2;
        var top = (height0 - size.height) / 2 + scrollTop;
        $targeturl.css({
                zIndex: "999",
                position: "absolute",
                left: left + "px",
                top: top + "px"
        });

}
/*close iframe*/
function closeEditor() {
        var we = document.getElementById("WidgetEditor");
        var la = document.getElementById("JS-layer");
        document.body.removeChild(we);
        document.body.removeChild(la);
        document.body.style.position = '';
}
/*close div*/
function closeEditorDiv(self, parent) {
        $(self).parents(parent).hide();
        $("#JS-layer").remove();
}